package com.coco.controller;

import com.coco.model.CollectionStatus;
import com.coco.model.RecordInfo;
import com.coco.service.CommonService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author GHOSTLaycoo
 * @date 2020/4/28 - 11:09
 */
@RestController
@RequestMapping("common")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @ApiOperation(value = "新增历史记录")
    @PostMapping("/saveHistory")
    public ResponseEntity<Integer> saveHistory(@RequestBody CollectionStatus collectionStatus, HttpServletRequest request){
        return ResponseEntity.ok(commonService.saveHistory(collectionStatus,request));
    }

    @ApiOperation(value = "删除该用户历史记录")
    @DeleteMapping("/deleteHistory")
    public ResponseEntity<Integer> deleteHistory(HttpServletRequest request){
        return ResponseEntity.ok(commonService.deleteHistory(request));
    }

    @ApiOperation(value = "搜索用户当日历史记录")
    @GetMapping("/getTodeyHistory")
    public ResponseEntity<List<RecordInfo>> getTodeyHistory(HttpServletRequest request){
        return ResponseEntity.ok(commonService.getTodeyHistory(request));
    }
}
